<template>
  <span v-if="value.toString().indexOf('.')==-1">{{ value.toFixed(0) }}</span>
  <span v-else>{{ value.toFixed(2) }}</span>
</template>

<script setup>
import { ref,reactive, watch } from 'vue'
import gsap from 'gsap'

const props= defineProps({
  num:{
    type:Number,
    default:0
  }
})

const value=ref(0)

function animate(){
  gsap.to(value,{
    value:props.num,
    duration:1, //动画持续时间 s
    ease: "strong.inOut",//强烈的先快后慢
  })
}

watch(()=>props.num,()=>{
  animate()
})

animate()

</script>